package com.gaodun.hk.domain.repository;

import com.gaodun.hk.domain.entity.SmsSendRecord;
import com.gaodun.hk.domain.mapper.SmsSendRecordMapper;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author fengyamin
 * @date 2021/2/18
 */
@Service
public class SmsSendRecordRepository {

    @Resource
    private SmsSendRecordMapper smsSendRecordMapper;

    public SmsSendRecord selectByPrimaryKey(Integer id) {
        return smsSendRecordMapper.selectByPrimaryKey(id);
    }

    public int insertSelective(SmsSendRecord smsSendRecord) {
        return smsSendRecordMapper.insertSelective(smsSendRecord);
    }

    public int updateByPrimaryKeySelective(SmsSendRecord smsSendRecord) {
        return smsSendRecordMapper.updateByPrimaryKeySelective(smsSendRecord);
    }


    public int updateStatusByPhoneAndMsgCode(SmsSendRecord smsSendRecord) {
        Example example = new Example(SmsSendRecord.class);
        example.createCriteria()
                .andEqualTo("phoneNum", smsSendRecord.getPhoneNum())
                .andEqualTo("providerMsgCode", smsSendRecord.getProviderMsgCode());
        return smsSendRecordMapper.updateByExampleSelective(smsSendRecord, example);
    }


    public int updateBatchMsgId(List<SmsSendRecord> list) {
        return smsSendRecordMapper.updateBatchMsgId(list);
    }

}
